const { Service } = require("egg");
const axios = require("axios");

class UserService extends Service {
  async find(params) {
    return new Promise((resolve, reject) => {
      const { username, page, per_page } = params;
      let url = `https://api.github.com/users/${username}/followers?page=${page}&per_page=${per_page}`;
      console.log("url------------", url);
      axios.get(url).then((res) => {
        // console.log("--------------------", res.data.length);
        resolve(res.data);
      });

      // let users = await getUsers();
      // return users; // ctx.body = userInfo;
    });
  }
}

module.exports = UserService;
